<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
$this->addCssFile('/project/apps/ecga/styles/style.css');
$this->addCssFile('/project/apps/ecga/styles/datagrid.css');
$this->addCssFile('/project/apps/ecga/styles/product.css');
$this->addCssFile('/project/apps/ecga/styles/productsearch.css');
$this->addCssFile('/project/apps/ecga/styles/dateselector.css');
$this->addCssFile('/statics/js/facebox/css/facebox.css');
$this->addScriptFile('/statics/js/tooltips/tooltips.js');
$this->addScriptFile('/statics/js/datagrid/datagrid.js');
$this->addScriptFile('/statics/js/facebox/facebox.js');
$this->addScriptFile('/project/apps/ecga/js/productselector.js');
$this->addScriptFile('/project/apps/ecga/js/dateselector.js');
$this->addScriptFile('/project/apps/ecga/js/tabswitchover.js');
$this->addScriptFile('/project/apps/ecga/js/locktable.js');
$this->addScriptFile('/project/apps/ecga/js/fusioncharts/fusioncharts.js');
$this->addScriptFile('/project/apps/ecga/js/showchart.js');
$this->addScriptFile('/project/apps/ecga/js/tiptext.js');
$this->addCssFile('/statics/js/datepicker/css/calendar-eightysix-default.css');
$this->addScriptFile('/statics/js/datepicker/calendar.js');
?>
<body>

         <style type="text/css">
                    a { color:#666; }
                    a:visited { color:#999; }
                    .subTitle td { height:30px; background:#ccc;padding-left:5px }
                    .statReport th { text-align:center; }
                    .dataItem td { height:30px; padding-left:5px }
                    span.positiveNumber { color:red } span.negative { color:green }
                    span.floatRight { float: right;}
                    .text { width:80px; }
                    a.quickSearch { color:green; }
                    a.quickSearch:hover { color:red; }
                    .locktable td,.locktable th{overflow:hidden;}
                    .chartShow div{ border-bottom: 1px solid #ccc; padding-bottom: 10px; margin-bottom: 20px;}
                    .chartShow .dime{ text-align: right; width:100%;}
         </style>

        <?php $this->import('tips'); ?>
        <div class="action-header">
                <h3><?php $this->put($table->name);?></h3>
                <p class="action-desc"><?php $this->put($table->desc); ?></p>
        </div>
        <?php if (count($table->getFilters()) > 0) :?>
        <div class="action-filter">
                <fieldset>
                        <legend><?php $this->put('过滤器');?></legend>

                </fieldset>
        </div>
        <div class="action-filterform">
        <fieldset>
         <form id="theForm" action="" method="GET">

         <?php foreach ($table->getFilters() as $filter): ?>
             <?php if ($filter->isSelect()): ?>
             <select name="<?php $this->put($filter->name);?>" id="<?php $this->put($filter->name);?>">
					<?php if (count($filter->bind) >= 2 || $filter->name == 'batch'): ?>
						<option value="<?php $this->put($filter->default);?>"><?php $this->put($filter->caption);?></option>
					<?php endif;?>
					<?php $this->htmlOptions($filter->bind, $filter->value)?>
             </select>
             <?php elseif ($filter->isText()):?>
             <input type="text" <?php if ($filter->readOnly !== false) : ?>readonly="<?php $this->put($filter->readOnly);?>"<?php endif;?> size="<?php $this->put($filter->size);?>" id="<?php $this->put($filter->name)?>" name="<?php $this->put($filter->name)?>" title="<?php $this->put($filter->caption)?>" value="<?php $this->put($filter->value)?>" />
			 <script type="text/javascript">new OverText($('<?php $this->put($filter->name)?>'));</script>
             <?php elseif ($filter->isRadio()): ?>
                        <?php $this->htmlRadio($filter->name, $filter->bind, $filter->value);?>
             <?php elseif ($filter->isTipText()): ?>
             <input type="text" class="tiptext" ajax="<?php $this->put($filter->ajax);?>" name="<?php $this->put($filter->name)?>" size="<?php $this->put($filter->size);?>" id="<?php $this->put($filter->name)?>" title="<?php $this->put($filter->caption)?>" value="<?php $this->put($filter->value)?>"/>
             <script type="text/javascript">
                        new OverText($('<?php $this->put($filter->name)?>'));
                        new TipText($('<?php $this->put($filter->name)?>'));
             </script>
             <?php else:?>
             <?php $this->put($filter->caption);?>
             <input type="text" class="text" id="<?php $this->put($filter->name)?>" name="<?php $this->put($filter->name)?>" value="<?php $this->put($filter->value)?>" />
             <?php endif;?>
             <?php endforeach;?>
             <!--
                <span class="caption">快捷方式：</span>
                <a class="quickSearch" href="javascript:;" search="yestday">昨天</a>
                <a class="quickSearch" href="javascript:;" search="week">本周</a>
                <a class="quickSearch" href="javascript:;" search="month">本月</a>
                <a class="quickSearch" href="javascript:;" search="quarter">本季度</a>
                -->
                <button type="submit" onclick="this.form.action='?a=show'"><?php $this->put('确定');?></button>
                <!--
                <button type="submit" onclick="this.form.action='?a=export'"><?php $this->put('导出');?></button>
                -->
        </form>

        </fieldset>
        </div>
        <?php endif;?>

        <div id="modelContainer" class="hidden"></div>
        <div class="datagrid">
                <div style=" margin:0 20px; ">

                        <?php $this->import('tables/' . $table->template);?>

                </div>
        </div>

        <?php $this->import('footer'); ?>
<script type="text/javascript">
        var radios = $$('input[type=radio]');
        radios.each(function(item, i){
             if ('displayField' === item.get('name')){
                     item.addEvent('click', function(event){
                            if ('hour' == this.get('value')) {
                                $('interval').setStyle('display', 'none');
                                $$('label[for=interval]')[0].setStyle('display', 'none');
                            }else{
                                $('interval').setStyle('display', 'inline');
                                $('interval').set('value', '');
                                $('interval').focus();
                                $('interval').blur();
                            }
                     });
                     if ('hour' == item.get('value') && item.get('checked')) {
                        $('interval').setStyle('display', 'none');
                        $$('label[for=interval]')[0].setStyle('display', 'none');
                     }
             }
        });
        var form = $('theForm');
        window.addEvent('domready', function() {

                    var setTab = new TabSwitchover('.tabs>li>a', '.tab-contents>div');
                    setTab.setActiveTabClass('selected');

                    var chartShow = new showchart();
                    //设置每种图表所用的Flash地址
                    chartShow.setChartPath('MSColumn3D', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/mscolumn3d.swf', false)?>');
                    chartShow.setChartPath('pie3D', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/pie3d.swf', false)?>');
                    chartShow.setChartPath('MSLine', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/msline.swf', false)?>');
                    chartShow.setChartPath('Bubble', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/bubble.swf', false)?>');
                    chartShow.setChartPath('Combination', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/mscolumn3dlinedy.swf', false)?>');
                    chartShow.setChartPath('StackedColumn3D', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/stackedcolumn3d.swf', false)?>');
                    chartShow.setChartPath('MSCombiDY2D', '<?php $this->imageByPath('/project/apps/ecga/js/fusioncharts/mscombidy2d.swf', false)?>');
                    //设置每个图表的数据
                    <?php foreach ($table->chartData as $type => $charts) : ?>
                             <?php foreach ($charts as $name => $chart) : ?>
                             chartShow.addChartData(
                                        '<?php $this->put($type, false)?>',
                                        '<?php $this->put($name, false)?>',
                                        '<?php $this->put($chart['xml'], false)?>',
                                        800, 400);
                             <?php endforeach;?>
                    <?php endforeach;?>
                    //设置select option动作
                    chartShow.setActions('#chartShow>p>select');
                    //激活每个select的第一个图表
                    $$('#chartShow>p>select').each(function (value) {
                             chartShow.render(value.getChildren('option')[0].value, value.name);
                    });
                var date = $('date');
                if (date) {
                        new CalendarEightysix('date', {format:"%Y-%m-%d", 'prefill':false});
                        $('date').readOnly = true;
                }

                var projectSB = $('projectId');
                if (projectSB) {
                        projectSB.addEvent('change', function(e){
                                projectId = e.target.value;
                                var jsonRequest = new Request.JSON({
                                        url: '/ajax.php', 
                                        onSuccess: function(msg){
                                                batchBox = $('batch');
                                                batchBox.empty();
                                                batchBox.grab( new Element('option', { value: '', text: '批次'}) );
                                                msg.each(function(item){
                                                        batchBox.grab( new Element('option', { value: item, text: item}) );
                                                });
                                        }
                                }).get({
                                        'a': 'getBatch', 
                                        'projectId': projectId
                                });
                        });
                }
         });

         function exportTable() {
            var hiddenInput = new Element('input', {
                name : 'a',
                value : 'export',
                type : 'hidden'
            }).inject(form);
            form.submit();
         }
</script>
</body>
</html>
